<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"
	contentType="text/html; charset=UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="pg" uri="http://jsptags.com/tags/navigation/pager"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>合众人寿公益平台客户管理系统</title>
		<style>
body,ul,ol,dl,dd,p,h1,h2,h3,h4,h5,h6,form,input,textarea,select,td,th {
	margin: 0;
	padding: 0;
	font-family: "宋体", Arial, Helvetica, sans-serif;
}

li {
	list-style: none;
}

input {
	background: none;
}

.clear {
	zoom: 1;
}

.clear:after {
	content: "";
	display: block;
	clear: both;
}
</style>
		<link href="<%=request.getContextPath()%>/html/css/Main.css"
			rel="stylesheet" type="text/css" />
		<script src="<%=request.getContextPath()%>/html/js/Calendar.js"
			charset="utf-8"></script>

		<SCRIPT type="text/javascript">
     function check(){
     	if(leftTrim(document.getElementById("memberName").value) == ''){
     	   alert("请输入姓名!");
     	   return false;
     	}
     	if(leftTrim(document.getElementById("idCard").value)== ''){
     	   alert("请输入身份证号!");
     	   return false;
     	}
     	if(document.getElementById("idCard").value != ''){
	     	if(! isIdCardNo(document.getElementById("idCard").value)){
	     	  return false;
	     	}
     	}
     	if(document.getElementById("gender").value == ''){
     	   alert("请输入性别!");
     	   return false;
     	}
     	if(leftTrim(document.getElementById("cellPhone").value) == ''){
     	   alert("请输入手机号码!");
     	   return false;
     	}
     	if(!(/^1[3|4|5|8][0-9]\d{8}$/.test(document.getElementById("cellPhone").value))){ 
			alert("不是完整或者正确的手机号"); 
			document.getElementById("cellPhone").focus(); 
			return false; 
		} 
     	if(document.getElementById("subCompanyId").value == ''){
     	   alert("请选择分公司!");
     	   return false;
     	}
     	if(document.getElementById("subCityId").value == ''){
     	   alert("请选择中支机构!");
     	   return false;
     	}
     	if(leftTrim(document.getElementById("donateRecord").value) == ''){
     	   alert("请输入捐赠记录!");
     	   return false;
     	}
     	var mail = document.getElementById("mail").value;
     	if(mail != ''){
	     	if(mail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1){
	     		alert("邮箱格式错误!");
	     		return false;
	     	}
     	}
     	var donateStuNum = document.getElementById("donateStuNum").value;
     	if(leftTrim(donateStuNum) == ''){
     	   document.getElementById("donateStuNum").value = 0;
     	}else{
     		if(!(/^\d+$/.test(donateStuNum))){
     			alert("捐助学生数必须为正整数!");
	     		return false;
     		}
     	}
     	
     	
     	document.getElementById("subComName").value = document.getElementById("subCompanyId").options[document.getElementById("subCompanyId").selectedIndex].innerText;
     	document.getElementById("subCityName").value = document.getElementById("subCityId").options[document.getElementById("subCityId").selectedIndex].innerText;
     	   return true;
     }
     
     
     function isIdCardNo(num)
        {
          var len = num.length, re; 
          if (isNaN(num.substring(0,len-1))) {alert("身份证输入的不是数字！"); return false;}
          if (len == 15)
            re = new RegExp(/^(\d{6})()?(\d{2})(\d{2})(\d{2})(\d{3})$/);
          else if (len == 18)
            re = new RegExp(/^(\d{6})()?(\d{4})(\d{2})(\d{2})(\d{3})(\d)$/);
          else {alert("身份证输入的数字位数不对！"); return false;}
          var a = num.match(re);
          if (a != null)
          {
            if (len==15)
            {
              var D = new Date("19"+a[3]+"/"+a[4]+"/"+a[5]);
              var B = D.getYear()==a[3]&&(D.getMonth()+1)==a[4]&&D.getDate()==a[5];
            }
            else
            {
              var D = new Date(a[3]+"/"+a[4]+"/"+a[5]);
              var B = D.getFullYear()==a[3]&&(D.getMonth()+1)==a[4]&&D.getDate()==a[5];
            }
            if (!B) {alert("输入的身份证号 "+ a[0] +" 里出生日期不对！"); return false;}
          }
          return true;
        }
        
        
        function   leftTrim(ui){  
	    var   notValid=/^\s/;  
	    while(notValid.test(ui)){  
	      ui=ui.replace(notValid,"");}  
       return   ui; 
       }  
	 </SCRIPT>

	</head>

	<body>
		<div class="container">
			<div class="wrap clear">
				<div class="sub_wp_right">
					<div class="rt_tt">
						<h3 class="tittle">
							爱心之旅活动/会员/添加会员信息
						</h3>
					</div>
					<div class="ct">
						<form action="<%=request.getContextPath()%>/subMember/saveSubMember.do"
							method="post" onsubmit="return check()">
							<input type="hidden" name="journeyLoveId" value="${journeyLoveId}" >
							<input type="hidden" name="memberEnjoyId" value="${memberEnjoyId}" >
							<div class="add">
								<table>
									<tr>
										<td class="right">
											<span>姓名<font color="red">(*)</font>：</span>
										</td>
										<td class="t2">
											<input type="text" name="subMember.sub_memberName" id="memberName" />
										</td>
										<td class="right">
											<span>性别<font color="red">(*)</font>：</span>
										</td>
										<td class="t2">
											<select name="subMember.sub_gender" id="gender">
												<option value="男" selected="selected">
													男
												</option>
												<option value="女">
													女
												</option>
											</select>
										</td>
									</tr>
									<tr>
										<td class="right">
											<span>身份证号<font color="red">(*)</font>：</span>
										</td>
										<td class="t2">
											<input type="text" name="subMember.sub_idCard" id="idCard"/>
										</td>
										<td class="right">
											<span>出生日期：</span>
										</td>
										<td class="t2">
											<input type="text" name="subMember.sub_birthday" id="birdate" onfocus="calendar()"/>
										</td>
									</tr>
									<tr>
										<td class="right">
											<span>手机号码<font color="red">(*)</font>：</span>
										</td>
										<td class="t2">
											<input type="text" name="subMember.sub_cellPhone" id="cellPhone" />
										</td>
										<td class="right">
											<span>电子邮件：</span>
										</td>
										<td class="t2">
											<input type="text" name="subMember.sub_email" id="mail"/>
										</td>
									</tr>
									<tr>
									    <td class="right">
											<span>兴趣爱好：</span>
										</td>
										<td class="t2">
										     <input type="text" name="subMember.sub_carType"/>
										</td>
										<td class="right">
											<span>车辆品牌：</span>
										</td>
										<td class="t2">
											<input type="text" name="subMember.sub_carBrand" />
										</td>
									</tr>
									<tr>
										<td class="right">
											<span>分公司<font color="red">(*)</font>：</span>
										</td>
										<td class="t2">
											<select name="subMember.subCompany" id="subCompanyId">
												<option value="${subMember.subCompany}">${subMember.subComName}</option> 
											</select>
										</td>
										
										<td class="right">
											<span>中支<font color="red">(*)</font>：</span>
										</td>
										<td class="t2">
											<select name="subMember.subCity" id="subCityId">
												 <option value="${subMember.subCity}" >${subMember.subCityName}</option>
											</select>
										</td>

									</tr>
									<tr>
									  <td class="right">
											<span>捐助学生数：</span>
										</td>
										<td class="t2" colspan="3">
											<input type="text" name="subMember.sub_donateStuNum"
												id="donateStuNum" />
										</td>
									</tr>
									<tr>
										<td class="right">
											<span>捐赠记录<font color="red">(*)</font>：</span>
										</td>
										<td colspan="3" class="t2">
											<textarea rows="6" cols="68" name="subMember.sub_donateRecord"
												id="donateRecord"></textarea>
										</td>
									</tr>
									<tr>
										<td class="right">
											<span>转介绍记录：</span>
										</td>
										<td colspan="3" class="t2">
											<textarea rows="6" cols="68" name="subMember.sub_reproduceIntroduce"></textarea>
										</td>
									</tr>
									<tr>
										<td class="right">
											<span>发帖纪录：</span>
										</td>
										<td colspan="3" class="t2">
											<textarea rows="6" cols="68" name="subMember.sub_forumPosting"></textarea>
										</td>
									</tr>
									<tr>
										<td class="right">
											<span>备注：</span>
										</td>
										<td colspan="3" class="t2">
											<textarea rows="6" cols="68" name="subMember.sub_remark"></textarea>
										</td>
									</tr>
									<tr>
                                    <td>
                                      <input type="hidden" name="subMember.subComName" id="subComName"/>
                                    </td>
                                    <td>
                                      <input type="hidden" name="subMember.subCityName" id="subCityName"/>
                                    </td>
                                  </tr>
								</table>
							</div>
							<div class="btn">
								<input type="submit" value="保存" />
								<input type="button" value="返回"
									onclick="javascript :history.back(-1);" />
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</body>
</html>
